package com.ddtv.video.videostreaming.adapter;

import com.ddtv.video.videostreaming.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class VideoListAdapter extends BaseAdapter{

	private String[] links;
	private LayoutInflater mInflater;

	public VideoListAdapter(Context context,String[] files){
		this.mInflater =  LayoutInflater.from(context);
		this.links = files;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return links.length;
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return links[position];
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {

		ViewHolder holder = null;

		if(convertView == null){
			holder = new ViewHolder();
			convertView = mInflater.inflate(R.layout.list_item, null);
			holder.imgView = (ImageView)convertView.findViewById(R.id.img_thumb_video);
			holder.txtView = (TextView)convertView.findViewById(R.id.txt_video_title);
			convertView.setTag(holder);
		}else{
			holder = (ViewHolder) convertView.getTag();
		}

		holder.txtView.setText(links[position]);

		return convertView;
	}

	static class ViewHolder {
		ImageView imgView;
		TextView txtView;
	}

}
